#!/bin/sh

# root mount point
RMPOINT=/mnt/media

# specific mount point
SMPOINT=$RMPOINT/$1

# mount cmd
MOUNT_DEV="mount -t vfat /dev/$1 $RMPOINT/$1 -o codepage=936,iocharset=gb2312"


case $1 in
	"sd"[a-z][0-9]|"sd"[a-z]|"mmcblk"[0-9]|"mmcblk"[0-9]"p"[0-9])
		mkdir -p $SMPOINT
		$MOUNT_DEV
		echo "$1" > $SMPOINT/.msdev;;
	*)
		echo "device $1 is unknown."
		exit;;
esac

case $1 in
	"sda1"|"mmcblk0"|"mmcblk0p1")
		ln -sf $SMPOINT $RMPOINT"1";;
	"sdb1"|"sda2"|"mmcblk1"|"mmcblk0p2")
		ln -sf $SMPOINT $RMPOINT"2";;
	"sdc1"|"sda3"|"mmcblk0p3")
		ln -sf $SMPOINT $RMPOINT"3";;
	"sdd1"|"sda4"|"mmcblk0p4")
		ln -sf $SMPOINT $RMPOINT"4";;
esac

sync

